#include <bits/stdc++.h>
using namespace std;
int n,m,q,a1,b1,a2,b2,vis[2005][2005],ans,res[101][101][101][101];
char s[2005][2005];
int read(){
    int s=0;
    char ch=getchar(),last=' ';
    while(ch<'0'||ch>'9')
        last=ch,ch=getchar();
    while(ch>='0'&&ch<='9')
        s=(s<<1)+(s<<3)+(ch^48),ch=getchar();
    return last=='-'?-s:s;
}
void dfs(int x,int y){
    vis[x][y]=q+1;
    if(x-1>=a1&&s[x-1][y]=='1'&&vis[x-1][y]!=q+1)
        dfs(x-1,y);
    if(x+1<=a2&&s[x+1][y]=='1'&&vis[x+1][y]!=q+1)
        dfs(x+1,y);
    if(y-1>=b1&&s[x][y-1]=='1'&&vis[x][y-1]!=q+1)
        dfs(x,y-1);
    if(y+1<=b2&&s[x][y+1]=='1'&&vis[x][y+1]!=q+1)
        dfs(x,y+1);
}
signed main(){
    freopen("unicom.in","r",stdin);
    freopen("unicom.out","w",stdout);
    n=read(),m=read(),q=read();
    for(int i=1;i<=n;i++)
        scanf("%s",s[i]+1);
    if(n<=100&&m<=100&&q>300){
        for(int i=1;i<=n;i++)
            for(int j=1;j<=m;j++){
                int cnt=0;
                for(int y=j;y<=m;y++){
                    if(y==j&&s[i][y]=='1')
                        cnt++;
                    if(y>j&&s[i][y]=='1'&&s[i][y-1]=='0')
                        cnt++;
                    res[i][j][i][y]=cnt;
                }
                for(int x=i+1;x<=n;x++){
                    cnt=0;
                    for(int y=j;y<=m;y++){
                        res[i][j][x][y]=res[i][j][x-1][y];
                        if(y==j&&s[x][y]=='1'&&s[x-1][y]=='0')
                            cnt++;
                        if(y>j&&s[x][y]=='1'&&s[x-1][y]=='0'&&s[x][y-1]=='0')
                            cnt++;
                        if(y>j&&s[x][y]=='1'&&s[x-1][y]=='1'&&s[x][y-1]=='1')
                            cnt--;
                        res[i][j][x][y]+=cnt;
                    }
                }
            }
        while(q--){
            a1=read(),b1=read(),a2=read(),b2=read();
            printf("%d\n",res[a1][b1][a2][b2]);
        }
        return 0;
    }
    while(q--){
        ans=0;
        a1=read(),b1=read(),a2=read(),b2=read();
        for(int i=a1;i<=a2;i++)
            for(int j=b1;j<=b2;j++)
                if(s[i][j]=='1'&&vis[i][j]!=q+1){
                    ++ans,
                    dfs(i,j);
                }
        printf("%d\n",ans);
    }
    return 0;
}